#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int t;
	cin >> t; 
	while(t--)
	{
		int n;
		cin >> n;
		vector <int> a(n+10);
		long double sum=0;
		int pos=0;
		for(int i=1;i<=n;i++)
		{
			cin >> a[i];
			sum=sum+a[i];
			if(a[i]<a[i-1]&&a[i]<a[i+1])
			{
				pos=i;
			}
		}
		double ave=sum/n;
		//cout << sum << endl;
		//cout << ave << endl;
		int cnt=0;
		if(a[1]<ave)
		{
			for(int i=1;i<=pos-2;i++)
			{
				sum=sum-a[i];
				cnt++;
			}
		}
		if(a[n]<ave)
		{
			for(int i=n;i>=pos+2;i--)
			{
				sum=sum-a[i];
				cnt++;
			}
		}
		//cout << cnt << endl;
		double nowave=sum/(n-cnt);
		cout << fixed << setprecision(20) << nowave << endl;
	}
}
